#ifndef ACCOUNT_H_INCLUDED
#define ACCOUNT_H_INCLUDED

//(* wxWidgets includes
#include <wx/panel.h>
#include <wx/toolbar.h>
#include <wx/grid.h>
#include <wx/bitmap.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
//#include <wx/arrstr.h>
//*)

//(* C/C++ includes
#include <vector>
//*)

//(* other includes
#include "../common/IPlugin.h"
#include "../common/stdafx.h"
#include "MySql/MySqlEmbeddedWrapper.h"
//*)

//(* defines
typedef std::vector<SColumn>           COLUMN_LIST;
typedef std::vector<SColumn>::iterator COLUMN_LIST_ITER;
//*)

//(* constants
//*)

class CAccount;

class CTransactionRegisterTable : public wxGrid
{
public:
    CTransactionRegisterTable(CAccount* pParent, wxWindowID ID, CAccountPlugin* pPlugin, CMySqlWrapper* pMyql);
    ~CTransactionRegisterTable();
    CAccount* GetAccount() const;
    CMySqlWrapper* GetMySql() const;
    CAccountPlugin* GetPlugin() const;

private:
    CAccount*                     m_pParent;
    CAccountPlugin*               m_pPlugin;
    CMySqlWrapper*                m_pMySql;
};

class CTransactionRegisterData : public wxGridTableBase
{
public:
    CTransactionRegisterData(CTransactionRegisterTable* pParent);
    ~CTransactionRegisterData();

    //(*Override from wxGridTableBase
    int GetNumberRows();
    int GetNumberCols();
    wxString GetValue(int Row, int Col);
    void SetValue(int Row, int Col, const wxString& Value);
    bool AppendCols(size_t NumCols = 1);
    bool InsertCols(size_t Pos = 0, size_t NumCols = 1);
    wxString GetColLabelValue(int Col);
    void SetColLabelValue(int Col, const wxString& Label);
    //*)

private:
    CTransactionRegisterTable*    m_pParent;
//    wxString                      m_Database;
//    wxString                      m_Table;
    size_t                        m_NumRows;
    COLUMN_LIST                   m_ColHeaderList;
};

class CAccount : public wxPanel
{
public:
    CAccount(CAccountManager* pParent, wxWindowID ID, SAccountInfo& AccountInfo, CAccountPlugin* pPlugin, CMySqlWrapper* pMySql);
    ~CAccount();
    const SAccountInfo* GetAccountInfo() const;
    bool SaveAccountData(const bool IsNewAccount);
    bool CreateTransactionTable();
    bool LoadTransactionTable();
    bool SaveTransaction(const STransaction& Transaction, const bool IsNewTransction);
    bool ViewTransaction(STransaction& Transaction, const bool IsNew, const bool CanEdit);
    void SetTotalBalance(const double Balance);
    bool CalculateTotalBalance();

private:
    CAccountManager*              m_pParent;
    SAccountInfo                  m_AccountInfo;
    CAccountPlugin*               m_pPlugin;
    CMySqlWrapper*                m_pMySql;
    wxToolBar*                    m_pToolbar;
    wxCheckBox*                   m_pHideReconciled;
    CTransactionRegisterTable*    m_pTransactionRegister;
};

#endif // ACCOUNT_H_INCLUDED
